package org.example.ctsbocc.config;

import jakarta.annotation.Resource;
import org.example.ctsbocc.interceptor.JwtInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Resource(name = "jwtInterceptor")
    private JwtInterceptor jwtInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor)
                .addPathPatterns("/**")  // 指定需要拦截的路径
                .excludePathPatterns("/api/verificationCode/generate",
                                     "/api/loginController/**",
                                     "/api/registerController/register");  // 排除不需要拦截的路径
    }
}
